<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#375EAB">
<title>Gosl &ndash; package ode</title>
<link type="text/css" rel="stylesheet" href="static/style.css">
<script type="text/javascript" src="static/godocs.js"></script>
<style type="text/css"></style>
</head>
<body>
<div id="page" class=\wide">
<div class="container">
<h1>Gosl &ndash; <b>ode</b> &ndash; Ordinary differential equations</h1>
use 'godoc cmd/github.com/cpmech/gosl/ode' for documentation on the github.com/cpmech/gosl/ode command 

<!--
	Copyright 2009 The Go Authors. All rights reserved.
	Use of this source code is governed by a BSD-style
	license that can be found in the LICENSE file.
-->
<!--
	Note: Static (i.e., not template-generated) href and id
	attributes start with "pkg-" to make it impossible for
	them to conflict with generated attributes (some of which
	correspond to Go identifiers).
-->

	<script type='text/javascript'>
	document.ANALYSIS_DATA = ;
	document.CALLGRAPH = ;
	</script>

	
		
		<div id="short-nav">
			<dl>
			<dd><code>import "github.com/cpmech/gosl/ode"</code></dd>
			</dl>
			<dl>
			<dd><a href="#pkg-overview" class="overviewLink">Overview</a></dd>
			<dd><a href="#pkg-index" class="indexLink">Index</a></dd>
			
			
				<dd><a href="#pkg-subdirectories">Subdirectories</a></dd>
			
			</dl>
		</div>
		<!-- The package's Name is printed as title by the top-level template -->
		<div id="pkg-overview" class="toggleVisible">
			<div class="collapsed">
				<h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
			</div>
			<div class="expanded">
				<h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
				
			</div>
		</div>
		

		<div id="pkg-index" class="toggleVisible">
		<div class="collapsed">
			<h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
		</div>
		<div class="expanded">
			<h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>

		<!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
			<div id="manual-nav">
			<dl>
			
			
				<dd><a href="#pkg-variables">Variables</a></dd>
			
			
				
				<dd><a href="#Plot">func Plot(dirout, fn string, res *Results, yfcn Cb_ycorr, xa, xb float64, argsAna, argsNum string, extra func())</a></dd>
			
				
				<dd><a href="#SimpleOutput">func SimpleOutput(first bool, dx, x float64, y []float64, args ...interface{}) (err error)</a></dd>
			
				
				<dd><a href="#WcAnalysis">func WcAnalysis(dirout, fnkey, method string, fcn Cb_fcn, jac Cb_jac, M *la.Triplet, ycfcn Cb_ycorr, ya []float64, xa, xb float64, orders []float64, show bool)</a></dd>
			
			
				
				<dd><a href="#Cb_fcn">type Cb_fcn</a></dd>
				
				
			
				
				<dd><a href="#Cb_jac">type Cb_jac</a></dd>
				
				
			
				
				<dd><a href="#Cb_out">type Cb_out</a></dd>
				
				
			
				
				<dd><a href="#Cb_ycorr">type Cb_ycorr</a></dd>
				
				
			
				
				<dd><a href="#ERKdat">type ERKdat</a></dd>
				
				
			
				
				<dd><a href="#R5cte">type R5cte</a></dd>
				
				
			
				
				<dd><a href="#Results">type Results</a></dd>
				
				
			
				
				<dd><a href="#Solver">type Solver</a></dd>
				
				
					
					<dd>&nbsp; &nbsp; <a href="#Solver.GetStat">func (o *Solver) GetStat() (s string)</a></dd>
				
					
					<dd>&nbsp; &nbsp; <a href="#Solver.Init">func (o *Solver) Init(method string, ndim int, fcn Cb_fcn, jac Cb_jac, M *la.Triplet, out Cb_out, silent bool)</a></dd>
				
					
					<dd>&nbsp; &nbsp; <a href="#Solver.SetTol">func (o *Solver) SetTol(atol, rtol float64)</a></dd>
				
					
					<dd>&nbsp; &nbsp; <a href="#Solver.Solve">func (o *Solver) Solve(y []float64, x, xb, Δx float64, fixstp bool, args ...interface{}) (err error)</a></dd>
				
					
					<dd>&nbsp; &nbsp; <a href="#Solver.Stat">func (o *Solver) Stat()</a></dd>
				
			
			
			</dl>
			</div><!-- #manual-nav -->

		

		
			<h4>Package files</h4>
			<p>
			<span style="font-size:90%">
			
				<a href="/src/github.com/cpmech/gosl/ode/auxiliary.go">auxiliary.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/bweuler.go">bweuler.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/dbg.go">dbg.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/defs.go">defs.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/erk.go">erk.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/fweuler.go">fweuler.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/mpiaux_linux.go">mpiaux_linux.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/ode.go">ode.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/plotting.go">plotting.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/radau5.go">radau5.go</a>
			
				<a href="/src/github.com/cpmech/gosl/ode/radau5_mpi.go">radau5_mpi.go</a>
			
			</span>
			</p>
		
		</div><!-- .expanded -->
		</div><!-- #pkg-index -->

		<div id="pkg-callgraph" class="toggle" style="display: none">
		<div class="collapsed">
			<h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
		</div> <!-- .expanded -->
		<div class="expanded">
			<h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
			<p>
			  In the call graph viewer below, each node
			  is a function belonging to this package
			  and its children are the functions it
			  calls&mdash;perhaps dynamically.
			</p>
			<p>
			  The root nodes are the entry points of the
			  package: functions that may be called from
			  outside the package.
			  There may be non-exported or anonymous
			  functions among them if they are called
			  dynamically from another package.
			</p>
			<p>
			  Click a node to visit that function's source code.
			  From there you can visit its callers by
			  clicking its declaring <code>func</code>
			  token.
			</p>
			<p>
			  Functions may be omitted if they were
			  determined to be unreachable in the
			  particular programs or tests that were
			  analyzed.
			</p>
			<!-- Zero means show all package entry points. -->
			<ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
		</div>
		</div> <!-- #pkg-callgraph -->

		
		
			<h2 id="pkg-variables">Variables</h2>
			
				<pre>var (
    <span class="comment">// Modified-Euler 2(1), order=2, error_est_order=2, nstages=2</span>
    <span id="ME2_a">ME2_a</span> = [][]<a href="/pkg/builtin/#float64">float64</a>{{0.0, 0.0},
        {1.0, 0.0}}
    <span id="ME2_b">ME2_b</span>  = []<a href="/pkg/builtin/#float64">float64</a>{1.0, 0.0}
    <span id="ME2_be">ME2_be</span> = []<a href="/pkg/builtin/#float64">float64</a>{0.5, 0.5}
    <span id="ME2_c">ME2_c</span>  = []<a href="/pkg/builtin/#float64">float64</a>{0.0, 1.0}

    <span class="comment">// Dormand-Prince 5(4), order=5, error_est_order=4, nstages=7</span>
    <span id="DP5_a">DP5_a</span> = [][]<a href="/pkg/builtin/#float64">float64</a>{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
        {1.0 / 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
        {3.0 / 40.0, 9.0 / 40.0, 0.0, 0.0, 0.0, 0.0, 0.0},
        {44.0 / 45.0, -56.0 / 15.0, 32.0 / 9.0, 0.0, 0.0, 0.0, 0.0},
        {19372.0 / 6561.0, -25360.0 / 2187.0, 64448.0 / 6561.0, -212.0 / 729.0, 0.0, 0.0, 0.0},
        {9017.0 / 3168.0, -355.0 / 33.0, 46732.0 / 5247.0, 49.0 / 176.0, -5103.0 / 18656.0, 0.0, 0.0},
        {35.0 / 384.0, 0.0, 500.0 / 1113.0, 125.0 / 192.0, -2187.0 / 6784.0, 11.0 / 84.0, 0.0}}
    <span id="DP5_b">DP5_b</span>  = []<a href="/pkg/builtin/#float64">float64</a>{35.0 / 384.0, 0.0, 500.0 / 1113.0, 125.0 / 192.0, -2187.0 / 6784.0, 11.0 / 84.0, 0.0}
    <span id="DP5_be">DP5_be</span> = []<a href="/pkg/builtin/#float64">float64</a>{5179.0 / 57600.0, 0.0, 7571.0 / 16695.0, 393.0 / 640.0, -92097.0 / 339200.0, 187.0 / 2100.0, 1.0 / 40.0}
    <span id="DP5_c">DP5_c</span>  = []<a href="/pkg/builtin/#float64">float64</a>{0.0, 1.0 / 5.0, 3.0 / 10.0, 4.0 / 5.0, 8.0 / 9.0, 1.0, 1.0}
)</pre>
				<p>
constants
</p>

			
		
		
			
			
			<h2 id="Plot">func <a href="https://github.com/cpmech/gosl/blob/master/ode/plotting.go?s=977:1089#L29">Plot</a></h2>
			<pre>func Plot(dirout, fn <a href="/pkg/builtin/#string">string</a>, res *<a href="#Results">Results</a>, yfcn <a href="#Cb_ycorr">Cb_ycorr</a>, xa, xb <a href="/pkg/builtin/#float64">float64</a>, argsAna, argsNum <a href="/pkg/builtin/#string">string</a>, extra func())</pre>
			<p>
Plot plot results
</p>

			
			

		
			
			
			<h2 id="SimpleOutput">func <a href="https://github.com/cpmech/gosl/blob/master/ode/plotting.go?s=599:689#L13">SimpleOutput</a></h2>
			<pre>func SimpleOutput(first <a href="/pkg/builtin/#bool">bool</a>, dx, x <a href="/pkg/builtin/#float64">float64</a>, y []<a href="/pkg/builtin/#float64">float64</a>, args ...interface{}) (err <a href="/pkg/builtin/#error">error</a>)</pre>
			<p>
SimpleOutput implements a simple output function
</p>

			
			

		
			
			
			<h2 id="WcAnalysis">func <a href="https://github.com/cpmech/gosl/blob/master/ode/auxiliary.go?s=333:493#L8">WcAnalysis</a></h2>
			<pre>func WcAnalysis(dirout, fnkey, method <a href="/pkg/builtin/#string">string</a>, fcn <a href="#Cb_fcn">Cb_fcn</a>, jac <a href="#Cb_jac">Cb_jac</a>, M *<a href="/pkg/github.com/cpmech/gosl/la/">la</a>.<a href="/pkg/github.com/cpmech/gosl/la/#Triplet">Triplet</a>, ycfcn <a href="#Cb_ycorr">Cb_ycorr</a>, ya []<a href="/pkg/builtin/#float64">float64</a>, xa, xb <a href="/pkg/builtin/#float64">float64</a>,
    orders []<a href="/pkg/builtin/#float64">float64</a>, show <a href="/pkg/builtin/#bool">bool</a>)</pre>
			<p>
work/correctness analysis
</p>

			
			

		
		
			
			
			<h2 id="Cb_fcn">type <a href="https://github.com/cpmech/gosl/blob/master/ode/defs.go?s=224:307#L1">Cb_fcn</a></h2>
			<pre>type Cb_fcn func(f []<a href="/pkg/builtin/#float64">float64</a>, h, x <a href="/pkg/builtin/#float64">float64</a>, y []<a href="/pkg/builtin/#float64">float64</a>, args ...interface{}) <a href="/pkg/builtin/#error">error</a> <span class="comment">// function</span>
</pre>
			<p>
callbacks
</p>


			

			

			
			
			

			

			
		
			
			
			<h2 id="Cb_jac">type <a href="https://github.com/cpmech/gosl/blob/master/ode/defs.go?s=325:413#L1">Cb_jac</a></h2>
			<pre>type Cb_jac func(dfdy *<a href="/pkg/github.com/cpmech/gosl/la/">la</a>.<a href="/pkg/github.com/cpmech/gosl/la/#Triplet">Triplet</a>, h, x <a href="/pkg/builtin/#float64">float64</a>, y []<a href="/pkg/builtin/#float64">float64</a>, args ...interface{}) <a href="/pkg/builtin/#error">error</a> <span class="comment">// Jacobian (must have at least all diagonal elements set)</span>
</pre>
			

			

			

			
			
			

			

			
		
			
			
			<h2 id="Cb_out">type <a href="https://github.com/cpmech/gosl/blob/master/ode/defs.go?s=473:555#L2">Cb_out</a></h2>
			<pre>type Cb_out func(first <a href="/pkg/builtin/#bool">bool</a>, h, x <a href="/pkg/builtin/#float64">float64</a>, y []<a href="/pkg/builtin/#float64">float64</a>, args ...interface{}) <a href="/pkg/builtin/#error">error</a> <span class="comment">// output</span>
</pre>
			

			

			

			
			
			

			

			
		
			
			
			<h2 id="Cb_ycorr">type <a href="https://github.com/cpmech/gosl/blob/master/ode/defs.go?s=586:649#L5">Cb_ycorr</a></h2>
			<pre>type Cb_ycorr func(y []<a href="/pkg/builtin/#float64">float64</a>, x <a href="/pkg/builtin/#float64">float64</a>, args ...interface{}) <span class="comment">// y(x) correct</span>
</pre>
			<p>
callbacks
</p>


			

			

			
			
			

			

			
		
			
			
			<h2 id="ERKdat">type <a href="https://github.com/cpmech/gosl/blob/master/ode/erk.go?s=225:454#L3">ERKdat</a></h2>
			<pre>type ERKdat struct {
    <span class="comment">// contains filtered or unexported fields</span>
}</pre>
			

			

			

			
			
			

			

			
		
			
			
			<h2 id="R5cte">type <a href="https://github.com/cpmech/gosl/blob/master/ode/radau5.go?s=303:910#L7">R5cte</a></h2>
			<pre>type R5cte struct {
    T  [][]<a href="/pkg/builtin/#float64">float64</a> <span class="comment">// T matrix</span>
    Ti [][]<a href="/pkg/builtin/#float64">float64</a> <span class="comment">// inv(T) matrix</span>
    <span class="comment">// contains filtered or unexported fields</span>
}</pre>
			

			

			

			
			
			

			

			
		
			
			
			<h2 id="Results">type <a href="https://github.com/cpmech/gosl/blob/master/ode/plotting.go?s=353:545#L5">Results</a></h2>
			<pre>type Results struct {
    Method <a href="/pkg/builtin/#string">string</a>      <span class="comment">// method name</span>
    Dx     []<a href="/pkg/builtin/#float64">float64</a>   <span class="comment">// step sizes [Noutput]</span>
    X      []<a href="/pkg/builtin/#float64">float64</a>   <span class="comment">// x values [Noutput]</span>
    Y      [][]<a href="/pkg/builtin/#float64">float64</a> <span class="comment">// y values [ndim][Noutput]</span>
}</pre>
			<p>
Results structure to hold numerical results
</p>


			

			

			
			
			

			

			
		
			
			
			<h2 id="Solver">type <a href="https://github.com/cpmech/gosl/blob/master/ode/ode.go?s=483:4331#L9">Solver</a></h2>
			<pre>type Solver struct {
    ZeroTrial <a href="/pkg/builtin/#bool">bool</a>    <span class="comment">// always start iterations with zero trial values (instead of collocation interpolation)</span>
    Atol      <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// absolute tolerance</span>
    Rtol      <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// relative tolerance</span>
    IniH      <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// initial H</span>
    NmaxIt    <a href="/pkg/builtin/#int">int</a>     <span class="comment">// max num iterations (allowed)</span>
    NmaxSS    <a href="/pkg/builtin/#int">int</a>     <span class="comment">// max num substeps</span>
    Mmin      <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// min step multiplier</span>
    Mmax      <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// max step multiplier</span>
    Mfac      <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// step multiplier factor</span>
    PredCtrl  <a href="/pkg/builtin/#bool">bool</a>    <span class="comment">// use Gustafsson&#39;s predictive controller</span>

    C1h        <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// c1 of HW-VII p124 =&gt; min ratio to retain previous h</span>
    C2h        <a href="/pkg/builtin/#float64">float64</a> <span class="comment">// c2 of HW-VII p124 =&gt; max ratio to retain previous h</span>
    LerrStrat  <a href="/pkg/builtin/#int">int</a>     <span class="comment">// strategy to select local error computation method</span>
    Pll        <a href="/pkg/builtin/#bool">bool</a>    <span class="comment">// parallel (threaded) execution</span>
    CteTg      <a href="/pkg/builtin/#bool">bool</a>    <span class="comment">// use constant tangent (Jacobian) in BwEuler</span>
    UseRmsNorm <a href="/pkg/builtin/#bool">bool</a>    <span class="comment">// use RMS norm instead of Euclidian in BwEuler</span>
    Verbose    <a href="/pkg/builtin/#bool">bool</a>    <span class="comment">// be more verbose, e.g. during iterations</span>

    <span class="comment">// derived variables</span>
    Distr <a href="/pkg/builtin/#bool">bool</a> <span class="comment">// MPI distributed execution. automatically set ON in Init if mpi is on and there are more then one processor.</span>
    <span class="comment">// contains filtered or unexported fields</span>
}</pre>
			<p>
Solver implements an ODE solver
</p>
<pre>Note: Distr is automatically set ON by Init if mpi is on and there are more then one processor.
      However, it can be set OFF after calling Init.
</pre>


			

			

			
			
			

			

			
				
				<h3 id="Solver.GetStat">func (*Solver) <a href="https://github.com/cpmech/gosl/blob/master/ode/ode.go?s=12540:12577#L498">GetStat</a></h3>
				<pre>func (o *<a href="#Solver">Solver</a>) GetStat() (s <a href="/pkg/builtin/#string">string</a>)</pre>
				
				
				
				
			
				
				<h3 id="Solver.Init">func (*Solver) <a href="https://github.com/cpmech/gosl/blob/master/ode/ode.go?s=4407:4517#L105">Init</a></h3>
				<pre>func (o *<a href="#Solver">Solver</a>) Init(method <a href="/pkg/builtin/#string">string</a>, ndim <a href="/pkg/builtin/#int">int</a>, fcn <a href="#Cb_fcn">Cb_fcn</a>, jac <a href="#Cb_jac">Cb_jac</a>, M *<a href="/pkg/github.com/cpmech/gosl/la/">la</a>.<a href="/pkg/github.com/cpmech/gosl/la/#Triplet">Triplet</a>, out <a href="#Cb_out">Cb_out</a>, silent <a href="/pkg/builtin/#bool">bool</a>)</pre>
				<p>
Init initialises ODE structure with default values and allocate slices
</p>

				
				
				
			
				
				<h3 id="Solver.SetTol">func (*Solver) <a href="https://github.com/cpmech/gosl/blob/master/ode/ode.go?s=6842:6885#L216">SetTol</a></h3>
				<pre>func (o *<a href="#Solver">Solver</a>) SetTol(atol, rtol <a href="/pkg/builtin/#float64">float64</a>)</pre>
				<p>
SetTol sets tolerances according to Hairer and Wanner suggestions. This routine also
checks for consistent values and only considers the case of scalars Atol and Rtol.
</p>

				
				
				
			
				
				<h3 id="Solver.Solve">func (*Solver) <a href="https://github.com/cpmech/gosl/blob/master/ode/ode.go?s=7222:7323#L230">Solve</a></h3>
				<pre>func (o *<a href="#Solver">Solver</a>) Solve(y []<a href="/pkg/builtin/#float64">float64</a>, x, xb, Δx <a href="/pkg/builtin/#float64">float64</a>, fixstp <a href="/pkg/builtin/#bool">bool</a>, args ...interface{}) (err <a href="/pkg/builtin/#error">error</a>)</pre>
				<p>
Solve solves from (xa,ya) to (xb,yb) =&gt; find yb (stored in y)
</p>

				
				
				
			
				
				<h3 id="Solver.Stat">func (*Solver) <a href="https://github.com/cpmech/gosl/blob/master/ode/ode.go?s=12053:12076#L484">Stat</a></h3>
				<pre>func (o *<a href="#Solver">Solver</a>) Stat()</pre>
				
				
				
				
			
		
	

	





	
	
		<h2 id="pkg-subdirectories">Subdirectories</h2>
	
	


	<div class="pkg-dir">
		<table>
			<tr>
				<th class="pkg-name">Name</th>
				<th class="pkg-synopsis">Synopsis</th>
			</tr>

			
			<tr>
				<td colspan="2"><a href="..">..</a></td>
			</tr>
			

			
				
					<tr>
						<td class="pkg-name" style="padding-left: 0px;">
							<a href="cmp/">cmp</a>
						</td>
						<td class="pkg-synopsis">
							
						</td>
					</tr>
				
			
				
					<tr>
						<td class="pkg-name" style="padding-left: 0px;">
							<a href="data/">data</a>
						</td>
						<td class="pkg-synopsis">
							
						</td>
					</tr>
				
			
				
					<tr>
						<td class="pkg-name" style="padding-left: 0px;">
							<a href="figs/">figs</a>
						</td>
						<td class="pkg-synopsis">
							
						</td>
					</tr>
				
			
		</table>
	</div>


	


<div id="footer">
<br /><br />
<hr>
<pre class="copyright">
Copyright (c) 2016, The Gosl Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of Gosl nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

</pre><!-- copyright -->
</div><!-- footer -->

</div><!-- container -->
</div><!-- page -->
</body>
</html>
